BEGIN TRANSACTION
GO
ALTER TABLE dbo.Items ADD
	UnitID tinyint NOT NULL CONSTRAINT DF_Items_UnitID DEFAULT 1
GO

---------------------------------------------------------------------------

USE [BS1]
GO
/****** Object:  Table [dbo].[Unit]    Script Date: 12/14/2014 13:27:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Unit](
	[UnitID] [tinyint] IDENTITY(1,1) NOT NULL,
	[UnitCode] [smallint] NOT NULL,
	[UnitName] [varchar](30) NOT NULL,
	[UnitNameUrdu] [varchar](30) NOT NULL,
	[Scale] numeric(7, 2) NOT NULL CONSTRAINT DF_Unit_Scale DEFAULT 1,
	[Discontinue] [bit] NOT NULL CONSTRAINT [DF_Unit_Discontinue]  DEFAULT ((0))	
 CONSTRAINT [PK_Unit] PRIMARY KEY CLUSTERED 
(
	[UnitID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

---------------------------------------------------------------------------

USE [BS1]
GO
/****** Object:  View [dbo].[vw_Items]    Script Date: 12/14/2014 14:49:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[vw_Items]
AS
SELECT     dbo.Items.GroupID, dbo.Groups.GroupCode, dbo.Groups.GroupName, dbo.Groups.GroupNameUrdu, dbo.Groups.Type, dbo.Items.UnitID, 
                      dbo.Unit.UnitCode, dbo.Unit.UnitName, dbo.Unit.UnitNameUrdu, dbo.Unit.Scale, dbo.Items.ItemID, dbo.Items.ItemCode, dbo.Items.ItemName, 
                      dbo.Items.ItemNameUrdu, dbo.Items.Discontinue, dbo.Items.PRate, dbo.Items.SRate, dbo.Items.ArticleNo
FROM         dbo.Unit RIGHT OUTER JOIN
                      dbo.Items ON dbo.Unit.UnitID = dbo.Items.UnitID LEFT OUTER JOIN
                      dbo.Groups ON dbo.Items.GroupID = dbo.Groups.GroupID


---------------------------------------------------------------------------